package com.gary.entity;

import java.util.Objects;

/**
 *  自定义的URL接口
 *      用于在实现远程过程调用时 指定对应的服务
 *      远程调用的数据结构使用
 *      Map<String, Map<MyURL, Class>>
 *          其中的MyURL为当前类 用于存放主机地址和端口号
 * @author pengrui3
 * @date 2020/12/11-21:26
 */
public class MyURL {
    private String hostAddress;
    private Integer port;

    public MyURL() {
    }

    public MyURL(String hostAddress, Integer port) {
        this.hostAddress = hostAddress;
        this.port = port;
    }

    public String getHostAddress() {
        return hostAddress;
    }

    public void setHostAddress(String hostAddress) {
        this.hostAddress = hostAddress;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    @Override
    public boolean equals(Object o) {

        if (o == null || !(o instanceof MyURL)) return false;
        if (o == null || getClass() != o.getClass()) return false;
        MyURL myURL = (MyURL) o;
        return hostAddress.equals(myURL.hostAddress) &&
                port.equals(myURL.port);
    }

    @Override
    public int hashCode() {
        return Objects.hash(hostAddress);
    }
}
